<div class="box-header with-border">
    <h3 class="box-title">模拟盘设置</h3>
    <!-- /.box-tools -->
</div>
<!-- /.box-header -->

<form role="form" onsubmit="return sub_setting_8()">
    <div class="box-body">
        <div class="form-group">
            <label>模拟盘是否开启</label>
            <input type="checkbox" id="moni_usable" class="on-off-button" data-size="mini" data-label-width="0" data-off-text="关闭" data-on-text="开启" data-handle-width="40" {$sys['moni_usable']==1?'checked':''}>
        </div>
        <div class="form-group">
            <label for="moni_odds" id="moni_odds_txt" style="color:{$sys['moni_usable']==2?'#a7a7a7':'#333333'}">模拟盘盈利机率</label>
            <input type="text" class="form-control" {$sys['moni_usable']==2?'disabled="disabled"':''} value="{$sys['moni_odds']}" id="moni_odds" placeholder="模拟盘盈利机率">
        </div>
    </div>
    <!-- /.box-body -->

    <div class="box-footer">
        <button type="submit" class="btn btn-primary">保存</button>
    </div>
</form>

<script>
    $(function() {
        $("#moni_usable").on('switchChange.bootstrapSwitch', function(event, state) {
            var moni_usable = 1;
            var info = "模拟盘已开启";
            if (state == true) {
                moni_usable = 1;
                info = "模拟盘已开启";
                $("#moni_odds").removeAttr("disabled");
                $("#moni_odds_txt").css("color", "#333333")
            } else {
                moni_usable = 2;
                info = "模拟盘已关闭";
                $("#moni_odds").attr("disabled", true);
                $("#moni_odds_txt").css("color", "#a7a7a7");
            }

            $.ajax({
                type:"POST",
                url : '__ADMIN__/'+moduleName+'/setting',
                dataType:"json",
                data:{
                    id:1,
                    moni_usable:moni_usable
                },
                beforeSend:showLoad,
                success:function(msg) {
                    if (msg.code == 0)
                        $.scojs_message(info, $.scojs_message.TYPE_OK);
                    else
                        $.scojs_message('开启&关闭&模拟盘失败', $.scojs_message.TYPE_ERROR);
                    hideLoad();
                }
            });
        });
    });
    function sub_setting_8(){

        var moni_odds = $("#moni_odds").val();
        if (moni_odds ==  "") {
            $.scojs_message("模拟盘盈利机率不能为空", $.scojs_message.TYPE_ERROR);
            return false;
        }
        $.ajax({
            type:"POST",
            url : '__ADMIN__/'+moduleName+'/setting',
            dataType:"json",
            data:{
                id:1,
                moni_odds:moni_odds
            },
            beforeSend:showLoad,
            success:function(msg) {
                if (msg.code == 0)
                    $.scojs_message(msg.msg, $.scojs_message.TYPE_OK);
                else
                    $.scojs_message(msg.msg, $.scojs_message.TYPE_ERROR);
                hideLoad();
            }
        });

        return false;
    }
</script>